<!DOCTYPE html>
<html>
<head>
    <#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />
    <#assign secSelect = JspTaglibs["http://www.casic304.cn/secSelect"] />
    <meta charset="utf-8">
    <title>质量综合分析报告</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/forms/currencyCss.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <style>
        .qbdms-TBinformation{margin-left: 0px;}
        .qbdms-TBinformationText{margin-left: 145px;}
    </style>
</head>
<body class="listBody">
<div class="qbdms-bodyDiv">
    <div class="qbdms-backDiv">
        <div class="layui-table-view-body" style="padding: 0 24px 24px;">
            <div class="qbdms-formTitle" style="border-bottom: 1px solid #E5F0FF">集团级质量综合分析报告 <i class="qbdms-returnOn closeWindow">返回</i></div>
            <form class="layui-form treeFormPreview" requrl="${ctx}/qbdms/wQbdQualityAnalysisReport/get"
                  lay-filter="wQbdQualityAnalysisReportDataForm" >
                <@fillDept.dept id="tbxx"/>
                <div class="layui-row">
                    <div style="width: 40%">
                        <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@secSelect.sec_select data_src=1 required=true name="secret"/>
                        </div>
                    </div>
                    <div style="width: 40%">
                        <label class="layui-form-label qbdms-label"  title="年度">年度<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input id="year" type="text" name="year"  placeholder="请输入"  lay-verify="required" lay-reqtext="年度是必填项"
                                   autocomplete="off" class="layui-input textInput"
                                   maxlength="50" fieldname="year">
                        </div>
                    </div>
                    <div style="width: 70%">
                        <label class="layui-form-label qbdms-label"  title="报告名称">报告名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="name"  placeholder="请输入" lay-verify="required" lay-reqtext="报告名称是必填项"
                                   autocomplete="off" class="layui-input textInput " maxlength="50" fieldname="name">
                        </div>
                    </div>
                    <div >
                        <label class="layui-form-label qbdms-label" title="附件">附件<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="button" class="layui-btn iconfont iconupload fileUpload qbdms-fileUp" id="attachmentUrlList"
                                   value="上传附件" lay-verify="fileRequired"/>
                            <i class="qbdms-fileUpText">支持单个附件上传，附件格式：doc  docx  pdf，附件大小限制：100M</i>
                            <input type="text" id="attachmentUrl" class="uploadInput" name="attachmentUrl" lay-verify="required" lay-reqtext="附件是必填项"
                                   fieldname="attachmentUrl" style="display: none">
                            <div class="uploadFileList" fileUploadName="attachmentUrl"></div>
                        </div>
                    </div>

                    <div style="width: 76%">
                        <label class="layui-form-label qbdms-label" title="备注">备注</label>
                        <div class="layui-input-block qbdms-input">
                            <textarea  name="remark" rows="2" class="layui-textarea" placeholder="请输入"
                                       maxlength="500" fieldname="remark"></textarea>
                        </div>
                    </div>
                </div>

                <div class="layui-hide">
                    <input type="text" name="id" placeholder="请输入"
                           autocomplete="off" class="layui-input " maxlength="50" fieldname="id">
                </div>

                <div class="layui-form-item" style="margin-top: 48px">
                    <p style="text-align: left;margin-left: 145px;">
                    <span id="hideAndShow" style="">
                        <a lay-submit lay-filter="wQbdQualityAnalysisReport" class="layui-btn btn-n privateSubmit qbdms-oneBtn"
                           requrl="${ctx}/qbdms/wQbdQualityAnalysisReport/save">提交</a>
                    </span>
                        <button type="reset" id="closeWindow" style="margin-left: 10px;"
                                class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">取消
                        </button>
                    </p>
                </div>
            </form>
        </div>
    </div>
    </div>
</div>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'setter', 'layer', 'common', 'laydate', 'jquery','propsHandle','publicMethods'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            publicMethods = layui.publicMethods,
            setter = layui.setter,  // 配置信息
            layer = layui.layer;
        var common = layui.common;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        var dateTimeFiledLen = $(".dateTimeFiled");
        for (var i = 0; i < dateTimeFiledLen.length; i++) {
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                , type: 'date'
                , trigger: 'click'
            });
        }

        //年度选择
        laydate.render({
            elem: '#year' //指定元素
            , type: 'year'
            , value: publicMethods.timeData(new Date(),3)
            , min: '2019-1-1'
            , trigger: 'click'
        });

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQualityAnalysisReport/view/list';
        });

        var runId = "${runId}";
        if (runId == null || runId == '') {
            $("#hideAndShow").show();
        }

        var index = parent.layer.getFrameIndex(window.name);

        common.updateForm({
            name: 'wQbdQualityAnalysisReportDataForm',
            idValue: "${id}",
            primary: "id",
            beforeSubmitFun: function (data) {
                //- 附件密级不能高于表单密级 开始 ------------------------------------------------------
                var selectMaxVal = 0;
                var formSecretVal = $("[name='secret']").val();
                $(".fileSecLevel select").each(function () {
                    selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
                });

                if (selectMaxVal > formSecretVal) {
                    layer.msg('附件密级不能高于表单密级。', {icon: 5});
                    return false;
                }
                //- 附件密级不能高于表单密级 结束 ------------------------------------------------------

                $(".uploadFileList").each(function (i,v) {
                    common.constructFileStr(v)
                });

                var files=[];
                //整理上传附件的隐藏域，将提交的字符串转为json对象
                $(".uploadInput").each(function () {
                    var uploadName = $(this).attr("name");
                    if (!$(this).val()) {
                        return;
                    }
                    data.field[uploadName] = eval($(this).val());
                    files=files.concat(eval($(this).val()));
                });

                return common.setFileLevel(files);
            },
            getCallback: function (data) {
                //-修改页面 初始化附件组件 开始 ------------------------------------------
                $('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);
                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel fileSecXg layui-input-inline">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '">' + fileSec + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont data-iconcommon_fujian" style="margin-right: 5px"></i>' + files[i].fileName + '</span><i class="iconfont data-iconcommon_close deleteFile" ></i></span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                            //$(this).find("select:last").attr("disabled", "disabled");
                        }
                    }
                });
                //-修改页面 初始化附件组件 结束 ------------------------------------------
            },
            updateCallback: function (data) {
                if (common.filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQualityAnalysisReport/view/list';
                    });
                } else {
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                }
                return false;
            }
        });

        //-- 附件上传 开始 --------------------------------------------------------------
        var secSelect = '<@secSelect.sec_select data_src=1 hasBlank=false/>'
        common.uploadfun(".fileUpload", {acceptMime:'${wjszsdsxlx}',
                exts:"${fileManagementUploadType}",
                secSelect:secSelect,
                isSub:false,
                upLoadSize:102400,
                isMultiFile:false,
                upLoadNumber:1,},
            function (res) {
                if (res.code === 0){
                    //文件名回填报告名称
                    $("input[name='name']").val(res.data.fileList[0].fileName);
                }}
        );
        //下载附件
        window.downFile = function (obj) {
            var fileId = $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId=" + fileId;
        }
        // 删除
        $(document).on('click', '.deleteFile', function () {
            $(this).parent().parent().siblings("button").show()
            $(this).parent().remove();
            $(".uploadFileList").each(function (i,v) {
                common.constructFileStr(v)
            });
        });
        //-- 附件上传 结束 --------------------------------------------------------------

    });
</script>


</body>
</html>